<?php
	 error_reporting(E_ALL);
?>
<style>
table tr td 
{
font-size:12px;
} 
table.nilai
{
border-collapse:collapse;
}
table.nilai, tr, td
{
border: 1px solid black;font-size:12px;
}
</style>
<script>
	 
 
	function reloadPage(){	
		var tahun_ajaran_id =$("#tahun_ajaran_id").val();	
		var tahun_ajaran_name =$("#tahun_ajaran_name").val();			
		var semester_id =$("#semester_id").val();	
		var kelas_tahun_ajaran_id =$("#kelas_tahun_ajaran_id").val();
		var tingkatan_id =$("#tingkatan_id").val();
		var studentid =$("#studentid").val();
		window.location.replace("index.php?r=karyawan/penilaian/report_nilai/ByStudent&&tahun_ajaran_name="+tahun_ajaran_name+"&tahun_ajaran_id="+tahun_ajaran_id+"&semester_id="+semester_id+"&kelas_tahun_ajaran_id="+kelas_tahun_ajaran_id+"&tingkatan_id="+tingkatan_id+"&studentid="+studentid);													
	} 
	  
   /*
	function updateData(data,nilai,notes){
		//if (confirm("Update data ?")){	
		var department_id =$("#department_id").val();		
		var karyawan_id =$("#karyawan_id").val();	
		var tahun_ajaran_id =$("#tahun_ajaran_id").val();	
		var semester_id =$("#semester_id").val();	
		var pelajaran_id =$("#pelajaran_id").val();	
		var kelas_id =$("#kelas_id").val();											
		var task_pelajaran_id =$("#task_pelajaran_id").val();		
		var task_pelajaran_detail_id =$("#task_pelajaran_detail_id").val();	
		var department_id =data.department_id;		
		var karyawan_id =data.karyawan_id;	
//		var tahun_ajaran_id =data.tahun_ajaran_id;	
//		var semester_id =data.semester_id;	
//		var pelajaran_id =data.pelajaran_id;	
//		var kelas_id =data.kelas_id;											
//		var task_pelajaran_id =data.task_pelajaran_id;	
//		var task_pelajaran_detail_id =data.task_pelajaran_detail_id;	
		var sid =data.sid;			
		var stat_id =data.stat_id;			 
		var student_id =data.id;		
		var nilai =nilai;
		var notes;
//		if (notes=="empty") {note="-";} else {note=notes;}
		var is_active=1;		
		if (stat_id==0){op="add";}else{op="edit";} 	 		
			window.parent.showLoader();			
			var editUrl = $("#tblData").jqGrid("getGridParam","editUrl");
			$.ajax({	
				url : editUrl,
				type:"GET",
				async:true,
				data: {op: op,student_id:student_id,id:stat_id,stat_id:stat_id,sid:sid,nilai:nilai,karyawan_id:karyawan_id,tahun_ajaran_id:tahun_ajaran_id,kelas_id:kelas_id,task_pelajaran_detail_id:task_pelajaran_detail_id,is_active:is_active,notes:notes},
				success: function(data) {
					if(data.actionStatus == 1){
						alert(data.actionMessage);
						return false;						
					}
					else
					if(data.actionStatus == 2){
						alert(data.actionMessage);
						return false;
					}						
				},
				complete:function(){
					window.parent.hideLoader();
					//reloadPage();
				}
			});			
		//}
			
	}   
	*/
 
</script>
 
<script>

function Tingkatan_OnChange_fill_Task_Detail(){ 
		window.parent.showLoader();	
 
		$filter = {"is_active":1,"wali_kelas_id":$("#karyawan_id").val(),"tingkatan_id":$("#tingkatan_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"kelas_tahun_ajaran_id",title_field:"kelas_name",group:"kelas_id,tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#kelas_tahun_ajaran_id",data);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	

		$filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"wali_kelas_id",title_field:"wali_kelas_id",group:"kelas_id,tingkatan_id"   },
			success: function(data) {
				printConsole(data.length+'--'  + "data1");
//				fillSelectData("#walikelas_id",data);	
				if(data.length==0){
				$("#walikelas_id").val(0);}
				else
				{$("#walikelas_id").val(data[0].value);}				
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		

		$filter = {"is_active":1,"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VStudentKelasTahunAjaran",filter: $filter,value_field:"student_id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#studentid",data,true);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		 				 
	} 
	
	function Tahun_Ajaran_OnChange_fill_all(){
		window.parent.showLoader();		
		$filter = {"is_active":1,"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"MSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#semester_id",data);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	

	
		$filter = {"is_active":1,"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"tingkatan_id",title_field:"tingkatan_name",group:"tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#tingkatan_id",data);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
				
		$filter = {"is_active":1,"wali_kelas_id":$("#karyawan_id").val(),"tingkatan_id":$("#tingkatan_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"kelas_id",title_field:"kelas_name",group:"kelas_id,tingkatan_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#kelas_tahun_ajaran_id",data);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	

		$filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"wali_kelas_id",title_field:"wali_kelas_id",group:"kelas_id,tingkatan_id"   },
			success: function(data) {
				printConsole(data.length+'--'  + "data1");
//				fillSelectData("#walikelas_id",data);	
				if(data.length==0){
				$("#walikelas_id").val(0);}
				else
				{$("#walikelas_id").val(data[0].value);}				
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		

		$filter = {"is_active":1,"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VStudentKelasTahunAjaran",filter: $filter,value_field:"student_id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#studentid",data,true);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});			 			 
	}   

  
 function KelasTahunAjaran_OnChange_fill_Student(){
 	window.parent.showLoader();	

		$filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"wali_kelas_id",title_field:"wali_kelas_id",group:"kelas_id,tingkatan_id"   },
			success: function(data) {
//				printConsole(data.length+'--'  + "data1");
//				fillSelectData("#walikelas_id",data);	
				if(data.length==0){
				$("#walikelas_id").val(0);}
				else
				{$("#walikelas_id").val(data[0].value);}				
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		 
			
		$filter = {"is_active":1,"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VStudentKelasTahunAjaran",filter: $filter,value_field:"student_id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#studentid",data,true);	
//				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		
 } 
  
	
 
</script>
 	
<div>
		<input type="hidden" id="department_id" name="department_id" value="<?php echo $department_id ?>"/>
   	    <input type="hidden" id="walikelas_id" name="walikelas_id" value="<?php echo $walikelas_id ?>"  />    
    <?php 
		$this->widget('application.components.widgets.TextField', 
			array("name"=>"department_name",
				"value"=>$department_name,
				"htmlOptions"=>"size='20'",
				"htmlOptions"=>"disabled",				
				"label"=>array(
					"value"=>Yii::t("label","Department"),
					"htmlOptions"=>"class='form' style='width:100px;'"
				)
			)
		);		
    ?>	    
</div>

<div>
    <?php 
		$this->widget('application.components.widgets.TextField', 
			array("name"=>"karyawan_name",
				"value"=>$karyawan_name,
				"htmlOptions"=>"size='20'",
				"htmlOptions"=>"disabled",				
				"label"=>array(
					"value"=>Yii::t("label","Guru"),
					"htmlOptions"=>"class='form' style='width:100px;'"
				)
			)
		);		
    ?>		
    <input type="hidden" id="karyawan_id" name="karyawan_id" value="<?php echo $karyawan_id ?>"  />
    <input type="hidden" id="karyawan_name" name="karyawan_name" value="<?php echo $karyawan_name ?>"  />

</div>    
 

  
<div style="float:rigth">&nbsp;
<?php 
    $this->widget('application.components.widgets.ActionBar', 
        array("menuAlign" => "right", 
            'items' => array(
                array(
                    'id' => "btnRefresh",
                    'title' => Yii::t("menu","Segarkan"),
                    'icon' => "images/action/Action-Refresh-icon.png",
                    'callback'=>"reloadPage"
                ),	/*				
                array(
                    'id' => "btnNew",
                    'title' => Yii::t("menu","Baru"),
                    'icon' => "images/action/Actions-document-new-icon.png",
                    'callback'=>"newData"
                ), */
                array(
                    'id' => "btnNew",
                    'title' => Yii::t("menu","Cetak"),
                    'icon' => "images/action/Actions-document-print-icon2.png",
                    'callback'=>"printData"
                ),					
                 
            ) 
        )
    );
?>
</div>	
 
	<div style="clear:both"></div>	
<div style="float:left;width:22%;">
	 		<input type="hidden" id="tingkatan_id" name="tingkatan_id" value="<?php echo $tingkatan_id ?>"/>
        
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Tahun Ajaran") ?></label>	
		<select name="tahun_ajaran_id" id="tahun_ajaran_id" onChange="Tahun_Ajaran_OnChange_fill_all()">
			<?php
				foreach ($tahunAjarans as $tahunAjaran){
					$selected = $tahun_ajaran_id == $tahunAjaran["tahun_ajaran_id"] ? "selected" : "";				
					echo"<option value='$tahunAjaran[tahun_ajaran_id]' $selected>$tahunAjaran[tahun_ajaran_name]</option>";
				}
			?>
		</select>
	</div>
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Semester") ?></label>	
		<select name="semester_id" id="semester_id"    >
			<?php
				foreach ($semesters as $semester){
					$selected = $semester_id == $semester["id"] ? "selected" : "";				
					echo"<option value='$semester[id]' $selected>$semester[name]</option>";
				}
			?>
		</select>
	</div>	
  	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Tingkatan") ?></label>	
		<select name="tingkatan_id" id="tingkatan_id"   onchange="Tingkatan_OnChange_fill_Task_Detail()"  >
			<?php
				foreach ($tingkatans as $tingkatan){
					$selected = $tingkatan_id == $tingkatan["tingkatan_id"] ? "selected" : "";				
					echo"<option value='$tingkatan[tingkatan_id]' $selected>$tingkatan[tingkatan_name]</option>";
				}
			?>
		</select>
	</div>    
      
  	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Kelas") ?></label>	
		<select name="kelas_tahun_ajaran_id" id="kelas_tahun_ajaran_id" onchange="KelasTahunAjaran_OnChange_fill_Student();"    >
			<?php
				foreach ($kelass as $kelas){
					$selected = $kelas_tahun_ajaran_id == $kelas["kelas_tahun_ajaran_id"] ? "selected" : "";				
					echo"<option value='$kelas[kelas_tahun_ajaran_id]' $selected>$kelas[kelas_name]</option>";
				}
			?>
		</select>
	</div>       
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Student") ?></label>	
 
		<select name="studentid" id="studentid"    >
			<?php
					$selected = $studentid == "" ? "selected" : "";				
					echo"<option value='' $selected>[ALL]</option>";				
				foreach ($students as $student){
					$selected = $studentid == $student["student_id"] ? "selected" : "";				
					echo"<option value='$student[student_id]' $selected>$student[name]</option>";
				}
			?>
		</select>
	</div>      
     
  	<div>
<input type="button" onclick="reloadPage()" value="view" />
	</div>         
</div>

<div style="float:left; width:78%">    
<?php    echo $viewdata; 
 ?>
	<table id="tblData"><tr></tr></table>
	<div id="navTblData"></div>
 </div>
  